package com.caocaog.market.controller;

import com.caocaog.market.annotation.IgnoreAuth;
import com.caocaog.market.service.IOrderBaseService;
import com.caocaog.market.service.ShopPromoService;
import com.caocaog.market.vo.OrderForOneVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequiredArgsConstructor
@Api(value = "shopPromoApi", tags = ApiShopPromoController.TABLE_MEANING)
@RequestMapping("/api/shopPromo")
public class ApiShopPromoController extends BaseController {

    private final IOrderBaseService orderBaseService;
    private final ShopPromoService shopPromoService;

    public static final String TABLE_MEANING = "API店铺优惠(活动)";

    private static final String COMPUTE = "计算符合的优惠信息";
    @IgnoreAuth
    @ApiOperation(value = COMPUTE, notes = COMPUTE)
    @PostMapping(value = "/computeConformPromo")
    public Result<?> computeConformPromo(@RequestBody OrderForOneVo orderForOneVo) {
        return Result.OK(this.orderBaseService.computeConformPromo(orderForOneVo));
    }

    private static final String GET = "获取店铺优惠信息";
    @IgnoreAuth
    @ApiOperation(value = GET, notes = GET)
    @GetMapping(value = "/getByShopId")
    public Result<?> getShopPromoByShopId(@ApiParam("shopId") @RequestParam("shopId") String shopId) {
        return Result.OK(this.shopPromoService.getShopPromoByShopId(shopId));
    }

}
